<script setup lang="ts">
import { inject, ref, type Ref} from 'vue';

// 孩子的孩子的组件
const totalCount = inject<Ref<number>>('totalCount',ref(0))
const updatatotalCount = inject('updatatotalCount',(num:number)=>{})
</script>

<template>
  <div class="sonson">
    <h3>后代:{{ totalCount }}</h3>
    <button @click="totalCount++">后代修改</button>
    <button @click="updatatotalCount(10)">调用函数+10</button>
  </div>
</template>